<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>修改密码</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="assets/layui/css/layui.css">
</head>
<body>

	<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
	<!--[if lt IE 9]>
		  <script src="assets/js/html5.min.js"></script>
		  <script src="assets/js/respond.min.js"></script>
		<![endif]-->
	<form id="changData" class="layui-form" onsubmit="return false" style="padding:50px 50px 0 50px">
		<div class="layui-form-item">
			<label class="layui-form-label">初始密码:</label>
			<div class="layui-input-inline">
				<input id="" type="password" name="psw" autocomplete="off" class="layui-input" value="" lay-verify="required|psw">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">新密码:</label>
			<div class="layui-input-inline">
				<input id="newPsw" type="password" name="newPsw" lay-verify="required|newPsw" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">确认密码:</label>
			<div class="layui-input-inline">
				<input id="surePsw" type="password" name="surePsw" lay-verify="required|surePsw" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item" style="text-align:center;margin-top:30px;">
			<button class="layui-btn" lay-submit="" lay-filter="submitBtn">确认</button>
			<button class="layui-btn cancel-btn">取消</button>
		</div>
	</form>
	<script src="assets/layui/layui.js"></script>
	<script src="assets/js/all.js"></script>
	<script type="text/javascript">
		layui.use(['form','layer','element'],function(){
			var form = layui.form,
				layer = layui.layer,
				$ = layui.$;
			//表单验证
			form.verify({
				psw: [/(.+){6,12}$/, '密码必须6到12位'],
				newPsw:[/(.+){6,12}$/, '密码必须6到12位'],
				surePsw:function(value){
					if(value != $("#newPsw").val()){
						$("#surePsw").val('');
						return '确认密码与密码不一致';
					}
				}
			});
			//监听提交
			form.on('submit(submitBtn)',function(data){				
				//var formData = $("#changData").serialize();
				//console.log(data.field);
				$.ajax({
					type:"post",
					url:"",
					data:data.field,
					dataType:'json',
					success:function(res){
						layer.msg(res.msg);
					}
					
				});
				return false;
			});
			$(".cancel-btn").on("click",function(){
				var index = parent.layer.getFrameIndex(window.name);
				parent.layer.close(index);
			})

		})
	</script>
</body>
</html>
